/**
 * Copyright(c) Yystar Technology Co.,Ltd
 * project：security
 * package：com.yystar.security.op.dao
 * fileName：UserDao.java
 * date：2013-6-27
 */
package com.yystar.security.op.dao;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.yystar.security.op.domain.User;
import com.yystar.security.support.jdbc.GenericDao;
import com.yystar.security.support.jdbc.Update;
import com.yystar.security.support.jdbc.Where;

/**
 * @author Vistaa Peng
 * @date 2013-6-27
 * @todo TODO
 * @modify	<BR>
 * 1.2013-6-27 Vistaa Peng Create file.
 */
@Repository
public class UserDao extends GenericDao<User>{

	public List<User> getUsers() {
		return super.find("select userId, username, password, enabled from users", new Object[]{});
	}
	
	public int updateUser(User user) {
		List<Where> wheres = new ArrayList<Where>();
		wheres.add(new Where("userId", user.getUserId()));
		List<Update> updates = new ArrayList<Update>();
		updates.add(new Update("username", user.getUserName()));
		updates.add(new Update("password", user.getPassword()));
		updates.add(new Update("enabled", user.getEnabled()));
		return super.update(user);
	}
	
}
